<template>
  <el-card class="introduce">
    <div class="order">
      <el-card class="order-item">
        <template #header>
          <div class="card-header">
            <span>今日订单数</span>
          </div>
        </template>
        <div class="item">1888</div>
      </el-card>
      <el-card class="order-item">
        <template #header>
          <div class="card-header">
            <span>今日浏览量</span>
          </div>
        </template>
        <div class="item">36271</div>
      </el-card>
      <el-card class="order-item">
        <template #header>
          <div class="card-header">
            <span>今日收藏量</span>
          </div>
        </template>
        <div class="item">3222</div>
      </el-card>
    </div>
  </el-card>
  <div class="charts-box">
    <div ref="lineNode" class="lineNode"></div>
  </div>
</template>

<script setup>
  import * as echarts from 'echarts'
  import { ref , onMounted} from 'vue'

  const lineNode = ref()

  onMounted(function() {
    const myChart = echarts.init(lineNode.value)

    // 绘制图表
    myChart.setOption( {
      title: {
        text: '每周商品数据'
      },
      tooltip: {
        trigger: 'axis',
        axisPointer: {
          type: 'cross',
          label: {
            backgroundColor: '#6a7985'
          }
        }
      },
      legend: {
        data: [ '订单量', '浏览量', '收藏量', '待支付']
      },
      toolbox: {
        feature: {
          saveAsImage: {}
        }
      },
      grid: {
        left: '3%',
        right: '4%',
        bottom: '3%',
        containLabel: true
      },
      xAxis: [
        {
          type: 'category',
          boundaryGap: false,
          data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
        }
      ],
      yAxis: [
        {
          type: 'value'
        }
      ],
      series: [
        {
          name: '订单量',
          type: 'line',
          stack: 'Total',
          areaStyle: {},
          emphasis: {
            focus: 'series'
          },
          data: [120, 132, 101, 134, 90, 230, 210]
        },
        {
          name: '浏览量',
          type: 'line',
          stack: 'Total',
          areaStyle: {},
          emphasis: {
            focus: 'series'
          },
          data: [220, 182, 191, 234, 290, 330, 310]
        },
        {
          name: '收藏量',
          type: 'line',
          stack: 'Total',
          areaStyle: {},
          emphasis: {
            focus: 'series'
          },
          data: [150, 232, 201, 154, 190, 330, 410]
        },
        {
          name: '待支付',
          type: 'line',
          stack: 'Total',
          areaStyle: {},
          emphasis: {
            focus: 'series'
          },
          data: [320, 332, 301, 334, 390, 330, 320]
        }
      ]
    })
  })


</script>



<style scoped lang="less">
  .order {
    display: flex;
    .order-item {
      text-align: center;
      flex: 1;
      margin:0 80px;
      font-size: 20px;
    }
  }
  .charts-box .lineNode {
    margin: 80px auto;
    width: 85%;
    height: 500px;
  }
  
</style>